#ifndef CHAR_DEV_APP_H
#define CHAR_DEV_APP_H
#include <string>
#include <fcntl.h>
#include <functional>
using std::string;

class CharDeviceAPP{
public:
    explicit CharDeviceAPP(string  filename,std::function<void(const bool)> fun = nullptr);
    int openDev(int model = O_RDWR);
    int writeDev(const void *_buf, size_t _n) const;
    ssize_t readDev(void *_buf, size_t _n) ;
    void closeDev();
public:
    void set_devChangeCallback(std::function<void(const bool)> fun);
protected:
    bool getdevStatus() const{return devStatus;};
    std::function<void(const bool)> devChangeFun = nullptr;
 private:
    void _setDevStatus(bool);
private:
    const  string filename;
    int fd = -1;
    bool devStatus = false;
};



#endif // CHAR_DEV_APP_H
